package com.hjl.json;

import com.hjl.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author ServivE
 * @version 0.1
 * @className JsonController
 * @description 返回JSON数据
 * @date 2024/8/13 9:33
 * @since jdk17
 */
@RequestMapping("json")
@Controller
public class JsonController {
    @PostMapping("getUser")
    @ResponseBody
    public User getUser(@RequestBody User user) {
        //接受的数据
        System.out.println("user = " + user);
        User user1 = new User();
        user1.setName("张三");
        user1.setAge(18);
        //响应的数据
        return user1;
    }
}
